function menuOneDivTwo(type) {
	if ("action" == type) {
		$("#onedive_two_action").attr("class", "tabsSelected");
		$("#onedive_two_read").attr("class", "tabsUnselected");
		$("#onedive_two_tree").attr("class", "tabsUnselected");

		$("#onedive_two_action_content").show();
		$("#onedive_two_read_content").hide();
		$("#onedive_two_tree_content").hide();
	}
	if ("read" == type) {
		$("#onedive_two_action").attr("class", "tabsUnselected");
		$("#onedive_two_read").attr("class", "tabsSelected");
		$("#onedive_two_tree").attr("class", "tabsUnselected");

		$("#onedive_two_action_content").hide();
		$("#onedive_two_read_content").show();
		$("#onedive_two_tree_content").hide();
	}
	if ("tree" == type) {
		$("#onedive_two_action").attr("class", "tabsUnselected");
		$("#onedive_two_read").attr("class", "tabsUnselected");
		$("#onedive_two_tree").attr("class", "tabsSelected");

		$("#onedive_two_action_content").hide();
		$("#onedive_two_read_content").hide();
		$("#onedive_two_tree_content").show();
	}
}

// 分享文章
function shareContent() {
	showCenterDiv("#popUpWrapInsideId");
	$("#lockUserActionBodyDivId").show();
	$("#popUpWrapInsideId").show();
}

function showCenterDiv(obj)
{
    var h1 = document.body.clientHeight;
    var h2 = document.documentElement.clientHeight;
    var isXhtml = (h2<=h1&&h2!=0)?true:false;
    var body = isXhtml?document.documentElement:document.body;
   
    var wh={left:0,top:0};
    var vwh={w:0,h:0};
    vwh.w=$.browser.msie?parseInt(body.clientWidth):parseInt(window.innerWidth);
    vwh.h=$.browser.msie?parseInt(body.clientHeight):parseInt(window.innerHeight);
    wh.left=(vwh.w/2)-parseInt($(obj).css("width"))/2;
    wh.top=body.scrollTop+(vwh.h/2)-parseInt($(obj).css("height"))/2;
    $(obj).css("top",wh.top);
    $(obj).css("left",wh.left);
    //return wh;
}

function closeShareWin() {
	$("#lockUserActionBodyDivId").hide();
	$("#popUpWrapInsideId").hide();
}

function copyShareUrl() {
	var t = $("#shareActionContentId").val();
	try {
		window.clipboardData.setData('text', t);
		alert("成功复制到剪贴板，可以粘贴到QQ、MSN等发送给朋友！");
	} catch (e) {
		alert("您的浏览器不支持复制功能!");
	}
}

function sendMail(url){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if($("#userInputEmail").val() == ""){
		alert("请输入朋友邮箱.");
		return;
	}
	
	var email = $("#userInputEmail").val().split(";");
	for(var i = 0 ; i < email.length ; i++){
		if(email[i].trim().length > 0){
		  if (!filter.test(email[i])){
		    alert("您输入了不合法邮箱,请仔细检查.");
			return;
		  }
		}
	}
	
	$.getJSON(url, {
		emails : $("#userInputEmail").val(),
		shareUrl : $("#shareActionContentId").val()
	}, function(callback) {
		if (callback.flag == "SUCCESS") {
			alert("邮件发送成功，请提醒朋友检查邮件！");
		}else if(callback.flag == "TIMEOUT"){
			alert("你登陆时间过长，请重新登录.");
			var loginUrl = url.replace("service/sendMail.json","login?type=redirect");
			window.location.href = loginUrl;
		}else{
			alert("发送邮件出现问题，请稍后再试！");
		}
	});
}

function copyShareUrl() {
	var t = $("#shareActionContentId").val();
	try {
		window.clipboardData.setData('text', t);
		alert("成功复制到剪贴板，可以粘贴到QQ、MSN等发送给朋友！");
	} catch (e) {
		alert("您的浏览器不支持复制功能!");
	}
}
